<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center postApost_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub postApost_fd0_0'>
          <view class='flex flex-wrap align-center postApost_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  postApost_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='postApost_fd0_0_c1_c0'>{{type==1 ? '发个帖' : '提个问'}}</text>
          </view>
          <view class='flex flex-wrap align-center justify-end postApost_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!--结束时间开始 -->
      <benben-picker ref="benbenWritePickerCodepicker1" :visible.sync="pickerDiy1706062096545" mode='date'
        :picker-height='88' :current='true' :mask-show='true' fields='day' :timeout='true' start-year='现在'
        end-year='2050-12-31' from-data='' :value.sync='end_time'>
        <template #picker-header>
          <view class='flex flex-wrap align-center justify-between postApost_picker1_0'>
            <text @tap="$refs.benbenWritePickerCodepicker1.cancel()">取消</text>
            <text>选择时间</text>
            <text class='postApost_picker1_0_c2' @tap="$refs.benbenWritePickerCodepicker1.pickerConfirm()">确定</text>
          </view>
        </template>
      </benben-picker>
      <!--结束时间结束 -->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout postApost_flex_2">
        <view class='flex flex-wrap align-center'>
          <benben-input class='flex-sub postApost_fd2_0_c0' type="text" :placeholder="`输入25字以内标题`" confirm-type="done"
            :maxlength="25" placeholder-style="color:rgba(191, 191, 191, 1);font-size:36rpx" v-model="title" />
        </view>
        <view class='flex flex-wrap align-center postApost_fd2_1'>
          <view class='flex flex-wrap postApost_fd2_1_c0'>
            <textarea :auto-height="true" class='flex postApost_input_fd2_1_c0' :placeholder="'写点什么...'" :maxlength="-1"
              placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" v-model="content" />

          </view>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center postApost_flex_3">
        <image class='postApost_fd3_0' mode="aspectFit" :src='STATIC_URL+"101.png"' @tap.stop="handleJumpDiy"
          data-type="navigateTo" :data-url="`/pages/fabu/classificationPage/classificationPage`"></image>
        <view class='flex flex-wrap align-center postApost_fd3_1' v-if="postcate_name">
          <text class='postApost_fd3_1_c0'>{{postcate_name}}</text>
        </view>
      </view>
      <view class="flex benben-flex-layout flex-wrap align-center postApost_flex_3_1">
        <view class="text-xs btnss" v-if="choos_user_name">@</view>
        <view class='flex flex-wrap align-center postApost_fd3_1' v-if="choos_user_name">
          <text class='postApost_fd3_1_c0'>{{choos_user_name}}</text>
        </view>
      </view>
      <!---flex布局flex布局结束-->
      <benben-popup v-model="popupShow1705301806437" :mask="true" :mask-close-able="false" mode='center' :z-index='999'>
        <!---存为草稿flex布局开始-->
        <view class="flex benben-flex-layout flex-wrap align-center">
          <view class='flex flex-direction flex-wrap align-center postApost_fd4_0'>
            <text class='postApost_fd4_0_c0'>确认保存帖子至草稿箱吗？</text>
            <view class='flex align-center postApost_fd4_0_c1'>
              <button class='postApost_fd4_0_c1_c0' @tap.stop="popupShow1705301806437=false">取消</button>
              <button class='postApost_fd4_0_c1_c1'>保存</button>
            </view>
          </view>
        </view>

        <!---存为草稿flex布局结束-->

      </benben-popup>
      <benben-popup v-model="popupShow1705300838843" :mask="true" :mask-close-able="true" mode='bottom' :z-index='999'>
        <!---flex布局flex布局开始-->
        <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout postApost_flex_5">
          <view class='flex flex-direction flex-wrap align-stretch flex-sub postApost_fd5_0'>
            <view class='flex flex-direction flex-wrap align-stretch postApost_fd5_0_c0'>

              <scroll-view class='postApost_fd5_0_c0_c0' :scroll-y='true'>
                <view class='flex flex-direction align-stretch benben-scroll flex'>
                  <view class='flex flex-wrap align-center postApost_fd5_0_c0_c0_c0'>
                    <!-- <text class='postApost_fd5_0_c0_c0_c0_c0'>请输入合集标题</text> -->
                    <input type="text" class="postApost_fd5_0_c0_c0_c0_c0 text-333" style="color: #333;"
                      v-model="hejiname" placeholder="请输入合集标题">
                  </view>
                  <!-- <input type="text" v-model="content" placeholder="请输入合集标题"> -->
                  <!-- @tap.stop="handleJumpDiy" data-type="navigateTo"
                      :data-url="`/pages/shouye/postquestionsDetails/postquestionsDetails?id=${itemD}`" -->
                  <view class='flex flex-wrap align-center justify-between postApost_fd5_0_c0_c0_c1'
                    v-for="(itemC,indexC) in post_arr" @tap.stop="handleJumpDiy" data-type="navigateTo"
                    :data-url="`/pages/shouye/postquestionsDetails/postquestionsDetails?id=${itemC.aid}`">
                    <view class='text-cut-2 postApost_fd5_0_c0_c0_c1_c0' style="width:500rpx">{{itemC.title}}</view>
                    <image class='postApost_fd5_0_c0_c0_c1_c1' @click.stop="delPostss(itemC,indexC)" mode="aspectFit"
                      :src='STATIC_URL+"48.png"'></image>
                  </view>
                  <!-- <view class='flex flex-wrap align-center justify-between postApost_fd5_0_c0_c0_c1'>
                    <text class='postApost_fd5_0_c0_c0_c1_c0'>错过上报OPT时间怎么办？</text>
                    <image class='postApost_fd5_0_c0_c0_c1_c1' mode="aspectFit" :src='STATIC_URL+"48.png"'></image>
                  </view> -->
                  <view class='flex flex-wrap align-center justify-center postApost_fd5_0_c0_c0_c3'
                    @tap.stop="handleJumpDiy" data-type="navigateTo"
                    :data-url="`/pages/fabu/selectPost/selectPost?posts_id=${JSON.stringify(post_arr)}`">
                    <image class='postApost_fd5_0_c0_c0_c3_c0' mode="aspectFit" :src='STATIC_URL+"100.png"'></image>
                    <text class='postApost_fd5_0_c0_c0_c3_c1'>添加帖子</text>
                  </view>
                </view>
              </scroll-view>

            </view>
            <view class='flex flex-wrap align-center justify-center postApost_fd5_0_c1' @click="saveHj">
              <button class='postApost_fd5_0_c1_c0'>保存</button>
            </view>
          </view>
        </view>

        <!---flex布局flex布局结束-->

      </benben-popup>
      <!---flex布局flex布局开始-->
      <!--    <view class="flex benben-flex-layout flex-wrap align-center">
        <benben-images-upload ref="benbenImagesUploadfd6_0" :maxlength="9">
          <template #content="{ num, maxlength, isShow, imgList }"> -->
      <view class="flex flex-wrap align-start flex postApost_fd6_0" v-if="images.length">

        <view v-for="(image, index) in images" :key="index" class='flex position-relative postApost_fd6_00'>
          <text class='fu-iconfont2 position-absolute postApost_fd6_000' @tap.stop="delImage(index)">&#xE8E7;</text>
          <image class='postApost_fd6_001' mode="aspectFill" :src='image'></image>
        </view>


      </view>
      <!--   </template>
        </benben-images-upload> -->
    </view>

    <!---flex布局flex布局结束-->
    <!---flex布局flex布局开始-->
    <!--  v-if="hejiname" -->
    <!-- && post_arr_n.length -->
    <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout postApost_flex_7"
      v-if=" post_arr.length " @click.stop="popupShow1705300838843=true">
      <view class='flex flex-wrap align-center justify-center postApost_fd7_0'>
        <view class='flex flex-wrap align-center'>
          <image class='postApost_fd7_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"102.png"'></image>
          <text class='postApost_fd7_0_c0_c1'>{{hejiname || '你的合集'}}</text>
        </view>
        <image class='postApost_fd7_0_c1' @click.stop="delpost" mode="aspectFit" :src='STATIC_URL+"48.png"'></image>
      </view>
    </view>
    <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout postApost_flex_7"
      v-if="question_operate_arr.length " @click.stop="popupShow1706061654145=true">
      <view class='flex flex-wrap align-center justify-center postApost_fd7_0'>
        <view class='flex flex-wrap align-center'>
          <image class='postApost_fd7_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"102.png"'></image>
          <text class='postApost_fd7_0_c0_c1'>选项</text>
        </view>
        <image class='postApost_fd7_0_c1' @click.stop="delXuanxiang" mode="aspectFit" :src='STATIC_URL+"48.png"'>
        </image>
      </view>
    </view>
    <!---flex布局flex布局结束-->
    <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex postApost_flex_8">
      <view class='flex flex-direction flex-wrap align-stretch flex-sub postApost_fd8_0'>
        <view class='flex flex-wrap align-center postApost_fd8_0_c0'>
          <image @click.stop="chooseImage" class='postApost_fd8_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"96.png"'>
          </image>
          <image @click.stop="chooseImage" class='postApost_fd8_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"97.png"'>
          </image>
          <image class='postApost_fd8_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"98.png"' @tap.stop="handleJumpDiy"
            data-type="navigateTo" :data-url="`/pages/fabu/choseetPerson/choseetPerson`"></image>
          <image class='postApost_fd8_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"99.png"'
            @tap.stop="popupShow1705300838843=true" v-if=" type=='1'"></image>
          <image class='postApost_fd8_0_c0_c0' mode="aspectFit" :src='STATIC_URL+"110.png"'
            @tap.stop="popupShow1706061654145=true" v-if=" type=='2'"></image>
        </view>
        <!-- /pages/fabu/choose_address/index -->
        <view class='flex flex-wrap align-center justify-between postApost_fd8_0_c1'>
          <view class='flex flex-wrap align-center' @tap="handleJump" data-url="/pages/fabu/choose_address/index">
            <image class='postApost_fd8_0_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"94.png"'></image>
            <view class="text-cut postApost_fd8_0_c1_c0_c1" style="width: 200rpx;">{{address || '添加地点'}}</view>
            <image class='postApost_fd8_0_c1_c0_c2' mode="aspectFit" :src='STATIC_URL+"95.png"'></image>
          </view>
          <view class='flex flex-wrap align-center'>
            <benben-flex-switch-new class-name='flex flex' v-model="is_nm" :disabled='false' :auto='true'>
              <template v-slot:checked>

                <view class='flex flex position-relative align-center'>
                  <image class='postApost_noCheckfd8_0_c1_c1_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"92.png"'>
                  </image>
                </view>

              </template>
              <template v-slot:unchecked>

                <view class='flex flex position-relative justify-end align-center'>
                  <image class='postApost_noCheckfd8_0_c1_c1_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"112.png"'>
                  </image>
                </view>

              </template>
            </benben-flex-switch-new>
            <text class='postApost_fd8_0_c1_c1_c1'>匿名发布</text>
          </view>
        </view>
        <view class='flex flex-wrap align-center justify-between postApost_fd8_0_c2'>
          <view class='flex flex-direction flex-wrap align-center' @click.stop="submit('1')">
            <image class='postApost_fd8_0_c2_c0_c0' mode="aspectFit" :src='STATIC_URL+"93.png"'></image>
            <text class='postApost_fd8_0_c2_c0_c1'>存为草稿</text>
          </view>
          <button class='postApost_fd8_0_c2_c1' @click.stop="submit('0')"> 发布</button>
        </view>
      </view>

    </view>
    <view :style="{height: '400rpx'}"></view>
    <benben-popup v-model="popupShow1706061654145" :mask="true" :mask-close-able="true" mode='bottom' :z-index='999'>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout postApost_flex_9">
        <view class='flex flex-direction flex-wrap align-stretch flex-sub postApost_fd9_0'>
          <view class='flex flex-direction flex-wrap align-stretch postApost_fd9_0_c0'>

            <scroll-view class='postApost_fd9_0_c0_c0' :scroll-y='true'>
              <view class='flex flex-direction align-stretch benben-scroll flex'>
                <!-- <view class='flex flex-wrap align-center postApost_fd9_0_c0_c0_c0'>
                  <text class='postApost_fd9_0_c0_c0_c0_c0'>请输入合集标题</text>
                </view> -->
                <view class='flex justify-between align-center justify-between postApost_fd9_0_c0_c0_c1'
                  v-for="(item,index) in question_operate_arr" :key="index">
                  <input type="text" class="postApost_fd9_0_c0_c0_c0_c0" placeholder="请输入" v-model="item.name" />
                  <image style="width: 32rpx;height: 32rpx;" @click="deloperate(item,index)" :src='STATIC_URL+"48.png"'
                    mode="aspectFill">
                  </image>
                </view>
                <!--  <view class='flex flex-wrap align-center justify-between postApost_fd9_0_c0_c0_c1'>
                  <text class='postApost_fd9_0_c0_c0_c1_c0'>错过上报OPT时间怎么办？</text>
                </view>
                <view class='flex flex-wrap align-center justify-between postApost_fd9_0_c0_c0_c1'>
                  <text class='postApost_fd9_0_c0_c0_c3_c0'>选项04</text>
                </view> -->
                <view class='flex flex-wrap align-center justify-center postApost_fd9_0_c0_c0_c4' @tap.stop="addQuest">
                  <image class='postApost_fd9_0_c0_c0_c4_c0' mode="aspectFit" :src='STATIC_URL+"100.png"'></image>
                  <text class='postApost_fd9_0_c0_c0_c4_c1'>添加新选项</text>
                </view>
              </view>
            </scroll-view>

          </view>
          <!-- <view class='flex flex-direction flex-wrap align-stretch postApost_fd9_0_c1'>
            <text class='postApost_fd9_0_c1_c0'>选项类型</text>
            <benben-select-diy ref="showSelectPopup1706061329800" class-name='flex flex' :items.sync="optionType"
              v-model="option_id" default-type="value" default-label="name" :allow-cancel='false' type="radio"
              :disabled='false'>
              <template v-for='(item,key0) in optionType'>
                <view v-if="item.isSelected" class='flex align-center justify-center flex postApost_fd9_0_c1_c1_c0'
                  :key="key0" @tap="$refs.showSelectPopup1706061329800.tapHandle(key0)">
                  <text class='postApost_fd9_0_c1_c1_c0_c0'>{{item.name}}</text>
                </view>
                <view v-else class='flex align-center justify-center flex postApost_fd9_0_c1_c1_c1' :key="key0"
                  @tap="$refs.showSelectPopup1706061329800.tapHandle(key0)">
                  <text class='postApost_fd9_0_c0_c0_c1_c0'>{{item.name}}</text>
                </view>
              </template></benben-select-diy>
          </view> -->
          <view class='flex flex-direction flex-wrap align-start postApost_fd9_0_c1'>
            <text class='postApost_fd9_0_c1_c0'>结束时间</text>
            <view class='flex flex-wrap align-center'>
              <benben-select-diy ref="showSelectPopup1706062237228" class-name='flex flex' :items.sync="finishType"
                v-model="finish_id" default-type="value" default-label="name" :allow-cancel='false' type="radio"
                :disabled='false'>
                <template v-for='(item,key0) in finishType'>
                  <view v-if="item.isSelected" class='flex align-center justify-center flex postApost_fd9_0_c1_c1_c0'
                    :key="key0" @tap="$refs.showSelectPopup1706062237228.tapHandle(key0)">
                    <text class='postApost_fd9_0_c1_c1_c0_c0'>{{item.name}}</text>
                  </view>
                  <view v-else class='flex align-center justify-center flex postApost_fd9_0_c1_c1_c1' :key="key0"
                    @tap="$refs.showSelectPopup1706062237228.tapHandle(key0)">
                    <text class='postApost_fd9_0_c0_c0_c1_c0'>{{item.name}}</text>
                  </view>
                </template></benben-select-diy>
              <view class='flex flex-direction flex-wrap align-center justify-center postApost_fd9_0_c2_c1_c1'
                @tap.stop="selelTimeFunc()">
                <image class='postApost_fd9_0_c2_c1_c1_c0' mode="aspectFit" :src='STATIC_URL+"109.png"'></image>
              </view>
            </view>
          </view>
          <view class='flex flex-wrap align-center justify-center postApost_fd9_0_c3'>
            <!-- submit  popupShow1706061654145=false -->
            <button class='postApost_fd9_0_c3_c0' @tap.stop="popupShow1706061654145=false">保存</button>
          </view>
        </view>
      </view>

      <!---flex布局flex布局结束-->

    </benben-popup>


  </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js';
  import {
    UploadImage
  } from '@/common/utils/index'
  import amapFile from '@/libs/amap-wx.js';

  export default {
    components: {},


    data() {
      return {
        "popupShow1706061654145": false,
        "popupShow1705300838843": false,
        "popupShow1705301806437": false,
        "fd2_1_c0": "",
        "pickerDiy1706062096545": false,
        "posts": {
          "aid": "",
          "type": "",
          "user_nickname": "",
          "title": "",
          "content": "",
          "images": [],
          "is_nm": "",
          "support_number": "",
          "collection_number": "",
          "comment_number": "",
          "end_time": "",
          "is_end": "",
          "address": "",
          "create_time": "",
          "user_id": "",
          "postoperate_id": "",
          "avatar": "",
          "is_follow": "",
          "array_title": "",
          "array_info": [],
          "state": ""
        },
        "optionType": [{
            "name": "单选",
            "value": "2",
            "image": ""
          }
          // ,{
          //   "name": "多选",
          //   "value": "3",
          //   "image": ""
          // },
        ],
        "option_id": "2",
        "finishType": [{
          "name": "一天后",
          "value": "1",
          "image": ""
        }, {
          "name": "一周后",
          "value": "2",
          "image": ""
        }, {
          "name": "从不",
          "value": "3",
          "image": ""
        }],
        "finish_id": "",
        "state": "1",
        "aid": "",
        type: '',
        title: '',
        content: '',
        images: [],
        is_nm: 0,
        is_arr: 0,
        end_time: '',
        question_type: '',
        address: '',
        choos_user: '',
        lng: '',
        lat: '',
        postcate_id: '',
        question_operate: '',
        post_arr_ids: '',
        post_arr_name: '',
        postcate_name: '',
        choos_user_name: '',
        post_arr: [],
        hejiname: '',
        question_operate_arr: [],
        locationaddress: {
          latitude: '',
          longitude: '',
          city: ''
        },
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        aid,
        id,
        type
      } = options
      if (aid !== undefined) this.aid = aid
      if (type !== undefined) this.type = type
      this.myAmapFun = new amapFile.AMapWX({
        key: '63259edc296cb943ffc26c92b77eba63'
      });
      if (aid != '0') {
        this.getDetail()
      }
      let that = this
      uni.getLocation({
        type: 'wgs84',
        // #ifdef APP
        geocode: true,
        // #endif
        isHighAccuracy: true,
        success: adr => {
          that.lng = adr.longitude
          that.lat = adr.latitude
        },
        fail: fail => {
          // that.$message.info(JSON.stringify(complete))
          console.log('complete', complete)
        },
        complete: complete => {
          // that.$message.info(JSON.stringify(complete))
          console.log('complete', complete)
        }
      })
    },
    onUnload() {
      uni.$off('customChooseLocation')
    },
    onReady() {

    },
    onShow() {

      uni.$on('fenlei', data => {
        this.postcate_id = data.aid
        this.postcate_name = data.name
      })
      uni.$on('userdata', data => {
        console.log('userdata', data)
        this.choos_user = data.aid
        this.choos_user_name = data.name
      })
      uni.$on('tiezi', data => {
        console.log('data', data)
        this.post_arr = data
        this.post_arr_ids = this.post_arr.map(item => {
          return item.aid
        }).join(',')
        this.post_arr_name = this.post_arr.map(item => {
          return item.title
        }).join(',')
      })
      uni.$on('customChooseLocation', res => {
        console.log(res)
        let location = res.name == res.address ? res.address : res.name == '我的位置' ? res.address : res.name + res
          .address
        this.address = location
        // this.address =location;
        this.lat = res.latitude
        this.lng = res.longitude
        // if(res.citys){
        //   this.address = `${res.citys.areap}${res.citys.areac}${res.citys.areax}`;
        // }
      })
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      delpost() {
        this.hejiname = ""
        this.post_arr = []
      },
      delXuanxiang() {
        this.question_operate_arr = []
        this.option_id = ''
        this.finish_id = ''
      },
      deloperate(item, index) {
        this.question_operate_arr.splice(index, 1)
      },
      // 获取详情
      getDetail() {
        this.$api.post(global.apiUrls.post65c04ef943328, {
          aid: this.aid,
          cate: 1
        }).then(res => {
          if (res.data.code == 1) {
            const objdata = res.data.data
            this.title = objdata.title
            this.content = objdata.content
            if (objdata.images.length) {
              this.images = objdata.images.split(',')
            }

            // console.log(this.images)
            this.is_nm = objdata.is_nm
            this.address = objdata.address

            this.lng = objdata.lng
            this.lat = objdata.lat


            this.postcate_id = objdata.postcate_id
            this.postcate_name = objdata.postcate_name
            this.choos_user = objdata.choos_user
            this.choos_user_name = objdata.choos_user_name
            // tiezi
            // if () {}
            this.hejiname = objdata.post_arr_name
            if (this.type == 1) {
              if (objdata.post_arr_ids) {
                this.post_arr = objdata.post_arr_ids.split(',')
                this.post_arr_n = objdata.post_arr_names.split(',')
              }

            } else {
              this.finish_id = objdata.end_time
              if (objdata.question_type == 2 || objdata.question_type == 3) { //问答
                let arrs = JSON.parse(objdata.question_operate)
                this.question_operate_arr = arrs.map(item => {
                  const obj = {
                    name: item
                  }
                  return obj;
                })
                this.option_id = objdata.question_type
              } else {
                // this.option_id = objdata.question_type
              }

              if (objdata.end_time != 3) {
                this.finish_id = objdata.end_time
              } else {
                this.end_time = objdata.end_time
              }
            }

          }
        })
      },
      delImage(index) {
        this.images.splice(index)
      },
      delPostss(item, index) {
        this.post_arr.splice(index, 1)
      },
      // 选择照片
      chooseImage() {
        let that = this
        uni.chooseImage({
          count: 3, // 默认3
          sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
          success: function(res) {
            // 开始上传
            new UploadImage(res.tempFiles, {
              complete: function(res1) {
                console.log('ressss', res1)
                res1.map((item) => {
                  that.images.push(item.id)
                })
                console.log(that.images)
              },
            })
          },
        })
      },
      /**
       * @func 地图选点
       */

      chooseLocation() {
        let _this = this
        uni.navigateTo({
          url: `/pages/fabu/choose_address/index`
          // url: `/pages/wode/choosepeopleFollow/addressview`
        })
      },
      addQuest() {
        this.question_operate_arr.push({
          name: ''
        })
      },
      saveHj() {
        this.popupShow1705300838843 = false
      },
      submit(is_draft) {

        // if (uni.getStorageSync('gugeaddress')) {
        //   this.lng = uni.getStorageSync("gugeaddress").longitude
        //   this.lat = uni.getStorageSync("gugeaddress").latitude
        //   this.address = uni.getStorageSync("gugeaddress").addresstxt
        // }
        let question_type = ''
        let imgs = ''
        if (!this.title) {
          this.$message.info('请输入标题')
          return;
        }
        if (!this.content) {
          this.$message.info('请输入内容')
          return;
        }
        // if (!this.postcate_id) {
        //   this.$message.info('请选择帖子分类')
        //   return;
        // }
        if (is_draft == '0') {
          if (!this.postcate_id) {
            this.$message.info('请选择帖子分类')
            return;
          }
          if (this.question_operate_arr.length == 0) {
            question_type = 1
          } else {
            question_type = this.option_id
          }
          if (this.finish_id == 3 || this.finish_id == 2 || this.finish_id == 1) {
            this.end_time = this.finish_id
          } else {
            console.log('yuuu', this.finish_id, this.end_time)
            this.end_time = this.end_time
          }
          this.post_arr_ids = this.post_arr.map(item => {
            return item.aid
          }).join(',')
          this.post_arr_name = this.post_arr.map(item => {
            return item.title
          }).join(',')
          if (this.question_operate_arr.length) {
            this.question_operate = this.question_operate_arr.map(item => {
              return item.name
            })
          }
          if (this.images.length) {
            imgs = this.images.join(',')
          }
          // if (!this.address) {
          //   this.$message.info('请选择位置')
          //   return;
          // }
        }

        // if (this.images.length == 0) {
        //   this.$message.info('请选择图片')
        //   return;
        // }
        // popupShow1705301806437=false
        // if (this.finish_id != 3) {
        //   this.end_time = this.finish_id
        // }
        if (this.type == 1) {
          // if (this.post_arr.length == 0) {
          //   this.$message.info('请选择帖子')
          //   return;
          // }
        }
        let hhhhname = ''

        if (this.post_arr_ids) {
          hhhhname = this.hejiname || '你的合集'
        }
        this.$api.post(global.apiUrls.post657a6698ad79f, {
          aid: this.aid,
          type: this.type, //类型1帖子2问答
          title: this.title,
          content: this.content,
          images: imgs, //图片集
          is_nm: this.is_nm, //是否匿名1是0否
          is_arr: this.post_arr_ids ? 1 : 0, //是否合集1是0否
          end_time: this.end_time, //问答结束时间 day
          question_type: question_type, //问题类型1问答2单选3多选
          address: this.address, //地点
          choos_user: this.choos_user, //艾特用户 多个逗号分隔
          choos_user_name: this.choos_user_name,
          lng: this.lng,
          lat: this.lat,
          postcate_id: this.postcate_id, //帖子分类ID
          postcate_name: this.postcate_name,
          question_operate: JSON.stringify(this.question_operate), //问题选项 接送串 {'问题1','问题2'}
          is_draft: is_draft, //是否存草稿 1是0否
          post_arr_ids: this.post_arr_ids, //合集帖子id 多个逗号分隔
          post_arr_names: this.post_arr_name,
          post_arr_name: hhhhname, //合集标题
        }).then(res => {
          if (res.data.code == 1) {
            if (is_draft == '1') {
              this.$message.info('保存成功')
              setTimeout(res => {
                uni.switchTab({
                  url: `/pages/tabBar/myPosts/myPosts`
                })
              }, 500)
            } else {
              if (this.id) {
                this.$message.info('编辑成功')
                uni.switchTab({
                  url: `/pages/tabBar/myPosts/myPosts`
                })
              } else {
                uni.redirectTo({
                  url: `/pages/fabu/publishSubmission/publishSubmission?aid=${res.data.data.aid}&type=${res.data.data.type}`
                })
              }
            }
          } else {
            this.$message.info(res.data.msg)
          }
        })
      },
      //选择时间
      selelTimeFunc() {
        // this.popupShow1706061654145 = false;
        this.finish_id = ''
        this.pickerDiy1706062096545 = true;
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    // min-height: calc(100vh - var(--window-bottom));
    background: rgba(248, 248, 248, 1);
    background-size: 100% auto;
  }

  .postApost_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .postApost_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .postApost_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .postApost_fd0_0_c0 {
    width: 120rpx;
  }

  .postApost_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .postApost_picker1_0_c2 {
    color: #4781f5;
  }

  .postApost_picker1_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .postApost_flex_2 {
    padding: 40rpx 32rpx 0rpx 32rpx;
  }

  .postApost_input_fd2_1_c0 {
    width: 100%;
    // height: 400rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
    padding: 0 12rpx;
    white-space: pre-wrap;
  }

  .postApost_fd2_1_c0 {
    width: 678rpx;
    padding: 24rpx 0rpx 24rpx 0rpx;
    color: #333;
    font-size: 28rpx;
  }

  .postApost_fd2_1 {
    // border: 1px solid #eee;
    margin: 24rpx 0rpx 0rpx 0rpx;
    // padding: 0 24rpx 0 0;
  }

  .postApost_fd2_0_c0 {
    height: 56rpx;
    color: rgba(51, 51, 51, 1);
    font-size: 36rpx;
  }

  .postApost_flex_3 {
    // position: fixed;
    // bottom: calc(480rpx + var(--window-bottom));
    // left: 32rpx;
    // z-index: 99;
    margin: 32rpx;
  }

  .postApost_flex_3_1 {
    // position: fixed;
    // bottom: calc(410rpx + var(--window-bottom));
    // left: 32rpx;
    margin: 32rpx;

    .btnss {
      width: 56rpx;
      height: 40rpx;
      line-height: 40rpx;
      border-radius: 8rpx;
      text-align: center;
      background-color: #FFF;
    }
  }

  .postApost_fd3_1_c0 {
    color: #333333;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .postApost_fd3_1 {
    background: rgba(255, 255, 255, 1);
    margin: 0rpx 0rpx 0rpx 16rpx;
    padding: 4rpx 16rpx 4rpx 16rpx;
    border-radius: 8rpx;
    background-size: 100% auto;
  }

  .postApost_fd3_0 {
    width: 56rpx;
    height: 40rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd4_0_c1_c1 {
    background: rgba(255, 255, 255, 1);
    font-size: 32rpx;
    color: rgba(100, 80, 235, 1);
    width: 270rpx;
    height: 101rpx;
    line-height: 101rpx;
    font-weight: 500;
  }

  .postApost_fd4_0_c1_c0 {
    border-right: 1px solid #eee;
    background: #fff;
    font-size: 32rpx;
    color: rgba(153, 153, 153, 1);
    width: 270rpx;
    height: 101rpx;
    line-height: 101rpx;
    font-weight: 400;
  }

  .postApost_fd4_0_c1 {
    border-top: 1px solid #eee;
  }

  .postApost_fd4_0_c0 {
    line-height: 44rpx;
    font-size: 28rpx;
    font-weight: 500;
    color: #333333;
    text-align: center;
    margin: 80rpx 40rpx 80rpx 40rpx;
  }

  .postApost_fd4_0 {
    background: #fff;
    width: 540rpx;
    background-size: 100% auto !important;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .postApost_flex_5 {
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .postApost_fd5_0_c1_c0 {
    background: rgba(100, 80, 235, 1);
    border-radius: 50rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .postApost_fd5_0_c1 {
    margin: 48rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd5_0_c0_c0_c3_c1 {
    color: #6450EB;
    font-size: 28rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .postApost_fd5_0_c0_c0_c3_c0 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 12rpx 0rpx 0rpx;
  }

  .postApost_fd5_0_c0_c0_c3 {
    border: 1px dashed rgba(100, 80, 235, 1);
    margin: 0rpx 24rpx 0rpx 24rpx;
    border-radius: 16rpx;
    padding: 24rpx 0rpx 24rpx 0rpx;
  }

  .postApost_fd5_0_c0_c0_c1_c1 {
    width: 28rpx;
    height: 28rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd5_0_c0_c0_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .postApost_fd5_0_c0_c0_c1 {
    background: rgba(255, 255, 255, 1);
    margin: 0rpx 24rpx 24rpx 24rpx;
    border-radius: 16rpx;
    background-size: 100% auto;
    padding: 24rpx 32rpx 24rpx 40rpx;
  }

  .postApost_fd5_0_c0_c0_c0_c0 {
    color: #BFBFBF;
    font-size: 28rpx;
    font-weight: 700;
    line-height: 32rpx;
  }

  .postApost_fd5_0_c0_c0_c0 {
    margin: 24rpx 24rpx 24rpx 24rpx;
  }

  .postApost_fd5_0_c0_c0 {
    touch-action: none;
    width: 672rpx;
    height: 632rpx;
  }

  .postApost_fd5_0_c0 {
    background: rgba(248, 248, 248, 1);
    margin: 48rpx 32rpx 0rpx 32rpx;
    height: 632rpx;
    border-radius: 16rpx;
    background-size: 100% auto;
  }

  .postApost_fd5_0 {
    padding: 0rpx 0rpx 48rpx 0rpx;
  }

  .postApost_fd6_01 {
    width: 164rpx;
    height: 164rpx;
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .postApost_fd6_001 {
    width: 164rpx;
    height: 164rpx;
    border-radius: 16rpx;
  }

  .postApost_fd6_000 {
    top: 0rpx;
    right: 0rpx;
    z-index: 2;
    color: #ff5536;
  }

  .postApost_fd6_00 {
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .postApost_fd6_0 {
    padding: 24rpx 0rpx 0rpx 24rpx;
  }

  .postApost_flex_7 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    margin: 56rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd7_0_c1 {
    width: 28rpx;
    height: 28rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    position: absolute;
    right: 32rpx;
  }

  .postApost_fd7_0_c0_c1 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .postApost_fd7_0_c0_c0 {
    width: 36rpx;
    height: 36rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 8rpx 0rpx 0rpx;
  }

  .postApost_fd7_0 {
    background: rgba(255, 255, 255, 1);
    border-radius: 16rpx;
    background-size: 100% auto;
    padding: 26rpx 32rpx 26rpx 32rpx;
    position: relative;
  }

  .postApost_flex_8 {
    background: rgba(255, 255, 255, 1);
    width: 750rpx;
    height: 400rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    background-size: 100% auto;
  }

  .postApost_fd8_0_c2_c1 {
    background: rgba(100, 80, 235, 1);
    border-radius: 50rpx;
    width: 558rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .postApost_fd8_0_c2_c0_c1 {
    color: #333333;
    font-size: 22rpx;
    font-weight: 400;
    line-height: 36rpx;
    margin: 6rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd8_0_c2_c0_c0 {
    width: 48rpx;
    height: 48rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd8_0_c2 {
    margin: 30rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd8_0_c1_c1_c1 {
    color: #333333;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .postApost_noCheckfd8_0_c1_c1_c0_c1_c0 {
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 30rpx;
    height: 30rpx;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .postApost_checkfd8_0_c1_c1_c0_c0_c0 {
    width: 30rpx;
    height: 30rpx;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
  }

  .postApost_fd8_0_c1_c0_c2 {
    width: 10rpx;
    height: 18rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 10rpx;
  }

  .postApost_fd8_0_c1_c0_c1 {
    width: 108rpx;
    color: #333;
    font-size: 24rpx;
  }

  .postApost_fd8_0_c1_c0_c0 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 8rpx 0rpx 0rpx;
  }

  .postApost_fd8_0_c1 {
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .postApost_fd8_0_c0_c0 {
    width: 48rpx;
    height: 48rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 48rpx 0rpx 0rpx;
  }

  .postApost_fd8_0_c0 {
    border-bottom: 1px solid #eee;
    padding: 28rpx 0rpx 28rpx 0rpx;
  }

  .postApost_fd8_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .postApost_flex_9 {
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .postApost_fd9_0_c3_c0 {
    background: rgba(100, 80, 235, 1);
    border-radius: 50rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .postApost_fd9_0_c3 {
    margin: 48rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd9_0_c2_c1_c1_c0 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .postApost_fd9_0_c2_c1_c1 {
    background: rgba(248, 248, 248, 1);
    width: 96rpx;
    height: 64rpx;
    border-radius: 12rpx;
    margin: 20rpx 0rpx 0rpx 0rpx;
    background-size: 100% auto;
  }

  .postApost_fd9_0_c1_c1_c1 {
    background: rgba(248, 248, 248, 1);
    margin: 20rpx 16rpx 0rpx 0rpx;
    border-radius: 12rpx;
    width: 136rpx;
    height: 64rpx;
    background-size: 100% auto;
  }

  .postApost_fd9_0_c1_c1_c0_c0 {
    color: #6450EB;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 28rpx;
  }

  .postApost_fd9_0_c1_c1_c0 {
    border: 1px solid rgba(100, 80, 235, 1);
    background: rgba(100, 80, 235, 0.08);
    margin: 20rpx 16rpx 0rpx 0rpx;
    width: 136rpx;
    height: 64rpx;
    border-radius: 12rpx;
    background-size: 100% auto;
  }

  .postApost_fd9_0_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 700;
    line-height: 32rpx;
  }

  .postApost_fd9_0_c1 {
    margin: 32rpx;
  }

  .postApost_fd9_0_c0_c0_c4_c1 {
    color: #6450EB;
    font-size: 28rpx;
    font-weight: 500;
    line-height: 32rpx;
  }

  .postApost_fd9_0_c0_c0_c4_c0 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 12rpx 0rpx 0rpx;
  }

  .postApost_fd9_0_c0_c0_c4 {
    border: 1px dashed rgba(100, 80, 235, 1);
    margin: 0rpx 24rpx 0rpx 24rpx;
    border-radius: 16rpx;
    padding: 24rpx 0rpx 24rpx 0rpx;
  }

  .postApost_fd9_0_c0_c0_c3_c0 {
    color: rgba(153, 153, 153, 1);
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .postApost_fd9_0_c0_c0_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .postApost_fd9_0_c0_c0_c1 {
    background: rgba(248, 248, 248, 1);
    margin: 0rpx 24rpx 24rpx 24rpx;
    border-radius: 16rpx;
    background-size: 100% auto;
    padding: 24rpx 32rpx 24rpx 40rpx;
  }

  .postApost_fd9_0_c0_c0_c0_c0 {
    color: #333;
    font-size: 28rpx;
    font-weight: 700;
    line-height: 32rpx;
  }

  .postApost_fd9_0_c0_c0_c0 {
    margin: 24rpx 24rpx 24rpx 24rpx;
  }

  .postApost_fd9_0_c0_c0 {
    touch-action: none;
    width: 672rpx;
    height: 632rpx;
  }

  .postApost_fd9_0_c0 {
    border-bottom: 1px solid #eee;
    background: rgba(255, 255, 255, 1);
    margin: 48rpx 32rpx 0rpx 32rpx;
    height: 632rpx;
    border-radius: 16rpx;
    background-size: 100% auto;
    padding: 0rpx 0rpx 32rpx 0rpx;
  }

  .postApost_fd9_0 {
    padding: 0rpx 0rpx 48rpx 0rpx;
  }
</style>
